package com.tedu.comment.tools;

import org.apache.logging.log4j.util.Base64Util;

import java.net.URLEncoder;

public class ImgCensor {
    public static String ImgCensor(){
        String Url="https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined";
        try {
            String filePath="D:\\test.jpg";
            byte[] imgData = FileUtil.readFileByBytes(filePath);
            String imgStr = Base64Util.encode(imgData.toString());
            String imgParams = URLEncoder.encode(imgStr, "UTF-8");
            String param = "image=" + imgParams;
            String accessToken = AuthService.getAuth();
            String result = HttpUtil.post(Url, accessToken, param);
            System.out.println(result);
            return result;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
